package com.cdc.guidepages.ScrollView;


import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;

/**
 * Created by cdc on 2018/4/9.
 */

public class MyScrollView extends ScrollView{

    private OnSrollChangedListener onSrollChangedListener;
    public MyScrollView(Context context) {
        super(context);
    }

    public MyScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public OnSrollChangedListener getOnSrollChangedListener() {
        return onSrollChangedListener;
    }

    public void setOnSrollChangedListener(OnSrollChangedListener onSrollChangedListener) {
        this.onSrollChangedListener = onSrollChangedListener;
    }

    @Override
    protected void onScrollChanged(int l, int top, int oldTop, int oldt) {
        super.onScrollChanged(l, top, oldTop, oldt);
        if(onSrollChangedListener!=null){
            onSrollChangedListener.onScrollChange(top,oldTop);
        }

    }

    public interface OnSrollChangedListener{
        void onScrollChange(int top,int oldTop);
    }
}
